import { Container, Header } from './index';
import ChildOne from "./ChildOne";
import ChildTwo from "./ChildTwo";
import ChildThird from "./ChildThird";
import store from '@/store'
// import ThemeContext from './ThemeContext';
import { useState, useEffect } from 'react';
// import othersStore from '@/store/others'
import { Provider } from 'react-redux'
export default function Parent () {
	const { supNum, oppNum, supTian, oppTian } = store.getState()
	const [num, setNum] = useState(0)
	const update = () => {
		setNum(num + 1)
	}

	useEffect(() => {
		console.log('数据变化了')
		let unsubscribe = store.subscribe(update)
		return () => {
			unsubscribe()
		}
	}, [num])

	return (
		<Provider store={store}>
			<Container>
				<Header>
					<div className="left">投票系统</div>
					<div className="right">参与人数：{supNum + oppNum}，参与甜甜投票人数：{supTian + oppTian}</div>
				</Header>
				<ChildOne />
				<ChildTwo />
				<ChildThird />
			</Container>
		</Provider >
	);
}
